var filePath = global.app.filePath,
    child_process = require('child_process'),
    spawn = child_process.spawn;

module.exports = function (url, fileName, callback) {
    var t = Date.now();
    var args = [];
    args.push('-N');
    args.push('-O');
    args.push(filePath + fileName);
    args.push(url);
    var wget = spawn('wget', args);
    console.log('wget ' + args.join(' '));
    wget.on('exit', function (code) {
        console.log(code);
        if (code === null) {
            callback({
                'error':1,
                'message':_str.toString()
            });
            return;
        }
        console.log('downed file ', Date.now() - t);
        console.log(fileName);
        callback({
            'error':0,
            'data':{
                'fileName':fileName
            }
        });
    });
};